package com.langfeiyes.pattern.composite.v2;


/**
 * 抽象父菜单--组件
 * 作用：定制叶子菜单跟组合菜单方法
 */
public abstract class Component {

    //抽象方法，叶子菜单与组合菜单都可以实现
    public  abstract void print();

    //是否leaf菜单
    public abstract boolean isLeaf();

    public void addChild(Component child){
        throw new UnsupportedOperationException("对象不支持添加子菜单操作");
    }

    public void removeChild(Component child){
        throw new UnsupportedOperationException("对象不支持删除子菜单操作");
    }

    public Component getChild(int index){
        throw new UnsupportedOperationException("对象不支持获取子菜单操作");
    }
}
